<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        //求和的变量
        var sum = 0;
        /* 函数定义 */
        function fn(n){
            //
            sum += n;
            n--
            if(n <= 0){
                return;
            }
            fn(n)
            // console.log(n);
        }
        fn(5)

        console.log("和为:"+sum);
    </script>
</body>
</html>